package game.module.kefu.processor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import game.HallServer;
import game.common.PlayingRoleMsgProcessor;
import game.entity.PlayingRole;
import game.module.kefu.logic.QuestionFeedbackManager;
import lion.common.MsgCodeAnn;
import lion.netty4.message.MyRequestMessage;
import lion.netty4.message.RequestMessageRaw;
import lion.netty4.message.RequestProtoMessage;
import lua.LuaMessageHall.C2SQuestionFeedback;
import lua.LuaMessageHall.S2CQuestionFeedback;

@MsgCodeAnn(msgcode = C2SQuestionFeedback.id, accessLimit = 500)
public class QuestionFeedbackProcessor extends PlayingRoleMsgProcessor {

	private static Logger logger = LoggerFactory.getLogger(QuestionFeedbackProcessor.class);
	@Override
	public void process(PlayingRole hero, RequestMessageRaw request) throws Exception {
		
		C2SQuestionFeedback reqMsg = C2SQuestionFeedback.parse(request);
		String question = reqMsg.question;
		String questionContent = reqMsg.question_content;
		int playerId = hero.getId();
		logger.info("C2SQuestionFeedback,playeyId={},question = {}", playerId,question);
		HallServer.executorService.execute(new Runnable() {
			@Override
			public void run() {
				
				QuestionFeedbackManager.getInstance().addQuestionFeedback(hero, question, questionContent);
				S2CQuestionFeedback respMsg = new S2CQuestionFeedback(0);
				hero.writeAndFlush(respMsg.build(hero.alloc()));
			}
		});
	}

	@Override
	public void processProto(PlayingRole playingRole, RequestProtoMessage request) throws Exception {
		// null
	}

	@Override
	public void processWebsocket(PlayingRole playingRole, MyRequestMessage request) throws Exception {
		// null
	}

	public static void main(String[] args) {
	}

}
